﻿// Write a boolean expression that returns if the bit at position p (counting from 0) in a given integer 
// number v has value of 1. Example: v=5; p=1 -> false.

using System;

class IfPBitIs1
{
    static void Main()
    {
        Console.Write("Enter integer number: ");
        int number = int.Parse(Console.ReadLine());
        Console.Write("Enter position: ");
        int position = int.Parse(Console.ReadLine());

        int mask = 1;
        int maskPosition = mask << position;
        int numbAndMaskPosition = number & maskPosition;
        int bit = numbAndMaskPosition >> position;
        bool bitBool;
        bitBool = bit == 1 ? true : false;

        Console.WriteLine("The bit in position {0} has value 1 : {1}", position, bitBool);
    }
}
